﻿Public Class Calculadora
    Dim numero1, numero2 As Double

    Private Sub validar()
        Try
            numero1 = txt_numero1.Text
            numero2 = txt_numero2.Text

        Catch ex As Exception
            MsgBox("Debe introducir un número, no letras.")

        End Try
    End Sub

    Private Sub btn_suma_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_suma.Click
        validar()
        Me.lab_resultado.Text = Math.Round(numero1 + numero2, 2)

    End Sub


    Private Sub btn_resta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_resta.Click
        validar()
        Me.lab_resultado.Text = Math.Round(numero1 - numero2, 2)
    End Sub

    Private Sub btn_producto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_producto.Click
        validar()
        Me.lab_resultado.Text = Math.Round(numero1 * numero2, 2)
    End Sub

    Private Sub btn_division_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_division.Click
        validar()
        Me.lab_resultado.Text = Math.Round(numero1 / numero2, 2)
    End Sub
End Class
